<?php include '../public/header.php' ?>
<?php include '../public/header_index.php' ?>
<link rel="stylesheet" type="text/css" href="/static/component/laytp/module/cityPicker/city-picker.css">
<style>
    .city-picker-span{height: 28px !important;overflow: hidden;}
    .layui-table-view .layui-table-fixed-r .layui-table-header div{border-bottom: 0!important;}
</style>
<body class="laytp-container">
<div id="opt_nav">
</div>

<div class="layui-card" id="search-form">
    <div class="layui-card-body">
        <form class="layui-form" id="TableSearchFormId" lay-filter="TableSearchForm" onkeydown="keyTableSearch('TableSearchForm', 'datalist')">
            <div class="layui-form-item">
                <div class="layui-row">
                    <div class="layui-col-md3">
                        <label class="layui-form-label">所属单位</label>
                        <div class="layui-input-block">
                            <div id="chanid" class="xmselect_div">
                                <div class="xmselect_title">请选择</div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <label class="layui-form-label">人员姓名</label>
                        <div class="layui-input-block">
                            <input type="text" name="name" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <label class="layui-form-label">身份证号</label>
                        <div class="layui-input-block">
                            <input type="text" name="idcard" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">性别</label>
                        <div class="layui-input-block">
                            <select name="sex" lay-filter="sex" >
                                <option value="">请选择</option>
                                <option value="男">男</option>
                                <option value="女">女</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">民族</label>
                        <div class="layui-input-block">
                            <div id="nation" class="xmselect_div">
                                <div class="xmselect_title">请选择</div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">籍贯</label>
                        <div class="layui-input-block">
                            <input type="text" name="jiguan" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">出生地</label>
                        <div class="layui-input-block">
                            <input type="text" name="areas" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">政治面貌</label>
                        <div class="layui-input-block">
                            <div id="mian" class="xmselect_div">
                                <div class="xmselect_title">请选择</div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">最高学历：</label>
                        <div class="layui-input-block">
                            <select id="gao_xue" name="gao_xue" lay-filter="gao_xue">
                                <option value="">请选择</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">干部级别：</label>
                        <div class="layui-input-block">
                            <select id="ganji" name="ganji" lay-filter="ganji">
                                <option value="">请选择</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">管理权限：</label>
                        <div class="layui-input-block">
                            <select id="guanquan" name="guanquan" lay-filter="guanquan">
                                <option value="">请选择</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">岗位类型：</label>
                        <div class="layui-input-block">
                            <select id="ganglei" name="ganglei" lay-filter="ganglei">
                                <option value="">请选择</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">是否项目经理：</label>
                        <div class="layui-input-block">
                            <select id="isxiang" name="isxiang" lay-filter="isxiang">
                                <option value="">请选择</option>
                                <option value="是">是</option>
                                <option value="否">否</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">劳动合同类型：</label>
                        <div class="layui-input-block">
                            <select id="laolei" name="laolei" lay-filter="laolei">
                                <option value="">请选择</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">缴纳社保地点：</label>
                        <div class="layui-input-block">
                            <select id="socaddr" name="socaddr" lay-filter="socaddr">
                                <option value="">请选择</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <div class="layui-form-item search-div">
                            <div class="layui-form-item layui-inline">
                                <button class="laytp-btn laytp-btn-md laytp-btn-primary" id="TableSearchButton" type="button"><i class="layui-icon layui-icon-search"></i>查询</button>
                                <button class="layui-btn layui-btn-primary" onclick="listTableReset()" id="TableSearchReset" type="reset" ><i class="layui-icon layui-icon-refresh"></i>重置</button>
                                <div id="search_open" onclick="toggle_search()">
                                    <i class="layui-icon layui-icon-down"></i>展开
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>

<div class="layui-card" id="table-card">
    <div class="layui-card-body">
        <div class="layui-row">
            <div class="layui-col-md12" id="table_list">
                <div class="layui-card-body">
                    <table id="datalist" lay-filter="datalist"></table>
                </div>
            </div>
        </div>
    </div>
</div>

<script type="text/html" id="test-dropdown-toolbar-barDemo">
    <div class="tab-list-authbut">
        <a href="javascript:;" class="bar_opt" onclick="auth_but_func_show('查看','{{d.LAY_TABLE_INDEX}}')">查看</a>
    </div>
</script>
<script type="text/html" id="toolbarDemo">
    <div class = "layui-btn-container">
    </div>
</script>
<script>
    var currButAuth, currTabData;
    layui.use(['table','form','soulTable'], function () {
        var table = layui.table, form = layui.form, soulTable = layui.soulTable;

        $('#TableSearchReset').click(function () {
            $('.xmselect_div>xm-select').find('.xm-label-block').css('display','none');
            $('.xmselect_div').append('<div class="xmselect_title">请选择</div>');
            searchTableFunc(form, table)
        });

        setSouTableExport('员工档案');
        table.render({
            elem: "#datalist",id: "datalist"
            ,url: facade.url(ask_cert_person_list),where: {state: '在职'}, page: true, height: 'full-140'
            ,soulSort: TabInit.soulSort,method: TabInit.method, toolbar: TabInit.toolbar, overflow: TabInit.overflow
            ,defaultToolbar: TabInit.defaultToolbar,filter: TabInit.filter
            ,request: TabInit.request,response: TabInit.response,contextmenu:get_table_contextmenu(soulTable)
            ,text: TabInit.text
            ,parseData: function (res) {
                currButAuth = res.data.butauth;
                tableButShow(currButAuth);

                xmselect_dan('chanid', res.data.chanid, res.data.is_chanid, function (res) {
                    setTimeout(function () {
                        searchTableFunc(form, table);
                    },100)
                })

                xmselect_dan('nation', res.data.nation, res.data.is_nation, function (res) {
                    setTimeout(function () {
                        searchTableFunc(form, table);
                    },100)
                })

                xmselect_dan('mian', res.data.mian, res.data.is_mian, function (res) {
                    setTimeout(function () {
                        searchTableFunc(form, table);
                    },100)
                })

                var gao_xue_str = '<option value="">请选择</option>';
                var gao_xue = res.data.gao_xue;
                for (var key in gao_xue){
                    if(res.data.is_gao_xue == gao_xue[key]){
                        gao_xue_str += '<option value="'+gao_xue[key]+'" selected>'+gao_xue[key]+'</option>';
                    }else {
                        gao_xue_str += '<option value="'+gao_xue[key]+'">'+gao_xue[key]+'</option>';
                    }
                }
                $("#gao_xue").html(gao_xue_str);

                var ganji_str = '<option value="">请选择</option>';
                var ganji = res.data.ganji;
                for (var key in ganji){
                    if(res.data.is_ganji == ganji[key]){
                        ganji_str += '<option value="'+ganji[key]+'" selected>'+ganji[key]+'</option>';
                    }else {
                        ganji_str += '<option value="'+ganji[key]+'">'+ganji[key]+'</option>';
                    }
                }
                $("#ganji").html(ganji_str);


                var guanquan_str = '<option value="">请选择</option>';
                var guanquan = res.data.guanquan;
                for (var key in guanquan){
                    if(res.data.is_guanquan == guanquan[key]){
                        guanquan_str += '<option value="'+guanquan[key]+'" selected>'+guanquan[key]+'</option>';
                    }else {
                        guanquan_str += '<option value="'+guanquan[key]+'">'+guanquan[key]+'</option>';
                    }
                }
                $("#guanquan").html(guanquan_str);


                var ganglei_str = '<option value="">请选择</option>';
                var ganglei = res.data.ganglei;
                for (var key in ganglei){
                    if(res.data.is_ganglei == ganglei[key]){
                        ganglei_str += '<option value="'+ganglei[key]+'" selected>'+ganglei[key]+'</option>';
                    }else {
                        ganglei_str += '<option value="'+ganglei[key]+'">'+ganglei[key]+'</option>';
                    }
                }
                $("#ganglei").html(ganglei_str);


                var laolei_str = '<option value="">请选择</option>';
                var laolei = res.data.laolei;
                for (var key in laolei){
                    if(res.data.is_laolei == laolei[key]){
                        laolei_str += '<option value="'+laolei[key]+'" selected>'+laolei[key]+'</option>';
                    }else {
                        laolei_str += '<option value="'+laolei[key]+'">'+laolei[key]+'</option>';
                    }
                }
                $("#laolei").html(laolei_str);


                var socaddr_str = '<option value="">请选择</option>';
                var socaddr = res.data.socaddr;
                for (var key in socaddr){
                    if(res.data.is_socaddr == socaddr[key]){
                        socaddr_str += '<option value="'+socaddr[key]+'" selected>'+socaddr[key]+'</option>';
                    }else {
                        socaddr_str += '<option value="'+socaddr[key]+'">'+socaddr[key]+'</option>';
                    }
                }
                $("#socaddr").html(socaddr_str);


                render_from();
                return {
                    "code": res.code,
                    "msg": res.message,
                    "count": res.data.data.total,
                    "data": res.data.data.data
                };
            }
            ,  cols: [
                [
                    {type: "checkbox", fixed: 'left',rowspan:2}
                    ,{type: 'numbers',title:'序号',fixed:'left',rowspan:2}
                    ,{field: 'deptid_name', title: '所属单位',fixed:'left',rowspan:2}
                    ,{field: 'name', title: '姓名',fixed:'left',rowspan:2}
                    ,{field: 'idcard', title: '身份证号码',rowspan:2}
                    ,{field: 'sex', title: '性别',rowspan:2}
                    ,{field: 'birdt', title: '出生年月',rowspan:2}
                    ,{field: 'age', title: '年龄',rowspan:2}
                    ,{field: 'tel', title: '联系方式',rowspan:2}
                    ,{field: 'nation_name', title: '民族',rowspan:2}
                    ,{field: 'jiguan', title: '籍贯',rowspan:2}
                    ,{field: 'areas', title: '出生地',rowspan:2}
                    ,{field: 'candt', title: '参加工作时间',rowspan:2}
                    ,{field: 'mian_name', title: '政治面貌',rowspan:2}

                    ,{field: '', title: '全日制学历',colspan:6,align:'center'}
                    ,{field: '', title: '在职学历',colspan:4,align:'center'}
                    ,{field: '', title: '最高学历',colspan:6,align:'center'}

                    ,{field: '', title: '专业技术职称',colspan:2,align:'center'}
                    ,{field: '', title: '工人技术等级',colspan:2,align:'center'}
                    ,{field: '', title: '职业资格证书',colspan:2,align:'center'}


                    ,{field: 'xianzhi', title: '现工作岗位及职务',rowspan:2}
                    ,{field: 'ren_xiandt', title: '任现职时间',rowspan:2}
                    ,{field: 'ren_zhidt', title: '任现职级时间',rowspan:2}
                    ,{field: 'ganji', title: '干部级别',rowspan:2}
                    ,{field: 'guanquan', title: '管理权限',rowspan:2}
                    ,{field: 'ganglei', title: '岗位类型',rowspan:2}
                    ,{field: 'intodt', title: '本单位入职时间',rowspan:2}

                    ,{field: 'isxiang', title: '项目经理',rowspan:2}
                    ,{field: 'xiangdt', title: '任职时间',rowspan:2}

                    ,{field: '', title: '社保关系',colspan:2,align:'center'}

                    ,{field: 'qianid_name', title: '合同签订单位',rowspan:2}
                    ,{field: 'laolei', title: '现劳动合同类型',rowspan:2}
                    ,{field: 'xianqizhi', title: '现劳动合同签订起止时间',rowspan:2}
                    ,{field: 'socaddr', title: '缴纳社保地点',rowspan:2}
                    ,{field: 'explain', title: '备注',rowspan:2}
                    ,{field: 'certnum', title: '证件数量',rowspan:2}
                    ,{field: 'filenums', title: '附件数量',rowspan:2}
                    ,{fixed: 'right', title:'操作', toolbar: '#test-dropdown-toolbar-barDemo',align:'center',width:200,rowspan:2}
                ],
                [
                    {field: 'yuan_xue', title: '学历'}
                    ,{field: 'yuan_yuan', title: '毕业院校'}
                    ,{field: 'yuan_zhuan', title: '专业'}
                    ,{field: 'yuan_xuewei', title: '学位'}
                    ,{field: 'yuan_dt', title: '毕业时间'}
                    ,{field: 'yuan_liu', title: '是否双一流'}

                    ,{field: 'zai_xue', title: '学历'}
                    ,{field: 'zai_yuan', title: '毕业院校'}
                    ,{field: 'zai_zhuan', title: '专业'}
                    ,{field: 'zai_dt', title: '毕业时间'}

                    ,{field: 'gao_xue', title: '学历'}
                    ,{field: 'gao_yuan', title: '毕业院校'}
                    ,{field: 'gao_zhuan', title: '专业'}
                    ,{field: 'gao_dt', title: '毕业时间'}
                    ,{field: 'gao_quan', title: '是否全日制'}
                    ,{field: 'gao_liu', title: '是否双一流'}

                    ,{field: 'zhi_cert_major', title: '专业'}
                    ,{field: 'zhi_cert_name', title: '级别'}
                    ,{field: 'ji_cert_major', title: '工种'}
                    ,{field: 'ji_cert_name', title: '等级'}
                    ,{field: 'zhu_cert_name', title: '名称'}
                    ,{field: 'zhu_cert_major', title: '专业'}


                    ,{field: 'sheguan', title: '社保关系'}
                    ,{field: 'shezhang', title: '社保缴纳账户'}
                ],
            ]
            , done: function (res) {
                soulTable.render(this);

                currTabData = res.data;
                $.each(currTabData, function(index,item){
                    var chk = $('tr[data-index=' + item.LAY_TABLE_INDEX + '] .tab-list-authbut');
                    for (var key in currButAuth) {
                        if(currButAuth[key].pagetype === 0 || currButAuth[key].pagetype === 1){
                            chk.append(' <a ' +
                                'href="javascript:;" ' +
                                'class="bar_opt layui-hide" ' +
                                'lay-event="search" ' +
                                'data-butname="'+currButAuth[key].butname+'" ' +
                                'data-title="'+currButAuth[key].title+'" ' +
                                'onclick="auth_but_func_'+currButAuth[key].butname+'(\''+currButAuth[key].title+'\', '+index+')"' +
                                '>'+currButAuth[key].title+'' +
                                '</a>');
                        }
                    }
                });
                show_tab_but(currTabData);
            }
        });

        table.on('tool(datalist)', function(obj){
            var data = obj.data;
            var layEvent = obj.event;

            if(layEvent == 'cert_num'){
                openPage('../cert/tong.php?personid='+data.id);
            }
        });

        listTableSearch(form, table);
    });

    function auth_but_func_show(buttitle, index){
        var trData = currTabData[index];
        openPage('show.php?id='+trData.id);
    }
    function auth_but_func_add(){
        openPageEdit('add.php?close=1');
    }
    function auth_but_func_edit(buttitle, index){
        var trData = currTabData[index];
        openPageEdit('edit.php?close=1&id='+trData.id);
    }
    function auth_but_func_delete(buttitle, index){
        var trData = currTabData[index];
        data_delete(ask_cert_person_del, {id:trData.id});
    }
    function auth_but_func_addcert(buttitle, index){
        var trData = currTabData[index];
        openPageEdit('../cert/add.php?close=1&personid='+trData.id);
    }
    function auth_but_func_addpin(buttitle, index){
        var trData = currTabData[index];
        openPageEdit('../cert_employ/add.php?close=1&personid='+trData.id);
    }
    function auth_but_func_editsocial(buttitle, index){
        var trData = currTabData[index];
        openPageEdit('editsocial.php?id='+trData.id);
    }
    function auth_but_func_editout(buttitle, index){
        var trData = currTabData[index];
        openPageEdit('editout.php?id='+trData.id);
    }
    function auth_but_func_import(buttitle){
        openPage('../public/import.php?url='+ask_import_cert_person+'&down='+encodeURI('人员')+'&daolei=1', '770px', '490px');
    }
    function auth_but_func_muldel(buttitle){
        var idArr = get_table_check_idarr();
        if(idArr.length < 1){
            facade.error(buttitle + "：请选择数据");return false;
        }
        data_delete(ask_cert_person_del, {id: idArr.join(',')});
    }
</script>
</body>
</html>
